package com.legendframework.core.dao.transaction;

import java.util.concurrent.TimeUnit;

/**
 * 带有加锁者名称的锁
 * 加锁者才能解锁
 */
public interface TransactionLock {

    void lock(String lockId);

    boolean tryLock(String lockId);

    boolean tryLock(String lockId , long time, TimeUnit unit) throws InterruptedException;

    /**
     * 释放锁
     * @param lockId
     * @return 是否释放成功
     */
    boolean unlock(String lockId);
}
